<%@ page import="com.xyc.pojo.User" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="java.util.List" %>
<%@ page import="com.xyc.pojo.Song" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>歌曲管理</title>
    <link href="css/index.css" rel="stylesheet" type="text/css"/>
    <style>
        table, tr, td {
            border: 1px solid #ccc;
        }

        table {
            text-align: center;
        }

        .row1 td, .row2 td, .row_hover td, .paging_row td {
            padding: 5px 10px;
            color: #666666;
            border: 1px solid #CBD6DE;
        }

        .row2 td {
            background: #ffffff;
        }

        .row1 td {
            background: #eeeeee;
        }

        .row_hover td {
            background: #FBFACE;
            color: #000000;
        }

        #quit {
            color: blue;
        }

        #quit:hover {
            cursor: pointer;
            color: #F4A460;
        }
    </style>
</head>
<body>
<div>
    <div id="top">
        <p class="title">&nbsp;&nbsp;&nbsp;&nbsp;
            <a href="index.jsp" style="cursor:pointer;">HappyMusic后台系统</a>
        </p>
        <p class="quit">&nbsp;<a href="login.html" onclick="return confirm('确认退出吗? ');quit()" id="quit">退出</a>&nbsp;&nbsp;&nbsp;
        </p>
        <p class="welcome">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;欢迎你&nbsp;<%=session.getAttribute("username")%>&nbsp;&nbsp;&nbsp;</p>
        <p id="showTime" class="showTime">&nbsp;&nbsp;</p>
    </div>
    <div id="left">
        <div class="rad"><a href="admin">系统设置</a></div>
        <div class="rad"><a href="myUser">用户管理</a></div>
        <div class="rad"><a href="mySong">歌曲管理</a></div>
        <div class="rad"><a href="myList">歌单管理</a></div>
    </div
    <div id="right">
        <!--显示系统设置的内容-->
        <p>欢迎进入HappyMusic后台管理系统</p>
        <table>
            <tr>
                <%--<td>编号</td>--%>
                <td>歌名</td>
                <td>作者</td>
                <td>发行日期</td>
                <td>会员</td>
                <%--<td>歌单</td>--%>
                <td>备注</td>
                <td>操作</td>
            </tr>
            <%
                List<Song> songList = (List<Song>) request.getAttribute("songList");
                for (int i = 0; i < songList.size(); i++) {
                    Song song = songList.get(i);
            %>
            <tr class="row<%=i%2+1%>">
                <%-- <td><%=song.getSong_id()%></td>--%>
                <td><%=song.getName()%>
                </td>
                <td><%=song.getAuthor()%>
                </td>
                <%
                    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                    String start = sdf.format(song.getStart());
                %>
                <td><%=start%>
                </td>
                <td><%=song.getIsVip()%>
                </td>
                <%--<td><%=song.getList()%></td>--%>
                <td><%=song.getMemo()%>
                </td>
                <td>
                    <a href="findSong?id_update=<%=song.getSong_id()%>">修改</a>
                    <a href="deleteSong?id_delete=<%=song.getSong_id()%>"
                       onclick="return confirm('确认删除&laquo;<%=song.getName()%>&raquo;吗? ')">删除</a>
                    <a href="addSong">添加</a>
                </td>
            </tr>
            <%}%>
        </table>
    </div>
    <div id="bottom">版权所有</div>
</div>
<script>
    function showTime() {
        var a = new Date();
        var b = a.toLocaleTimeString();
        var c = a.toLocaleDateString();
        document.getElementById("showTime").innerHTML = c + "&nbsp" + b;
    }

    setInterval(function () {
        showTime()
    }, 1000);

    function quit() {
        //防止页面后退
        history.pushState(null, null, document.URL);
        window.addEventListener('popstate', function () {
            history.pushState(null, null, document.URL);
        });
    }
</script>
</body>
</html>